cmake_minimum_required(VERSION 3.17)
project(ctest C)

set(CMAKE_C_STANDARD 99)

# 根据平台调整使用的动态库名称
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
    SET(LIBRARIES liboes.so)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "MSYS")
    SET(LIBRARIES liboes.dll)
ELSE ()
    MESSAGE(STATUS "other platform: ${CMAKE_SYSTEM_NAME}")
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")

include_directories(../header)
link_directories(${PROJECT_SOURCE_DIR}/libs)

# 在完成可执行程序构建后，复制动态库到debug的build目录，便于调试
#add_custom_command(TARGET goestest POST_BUILD
#        COMMAND ${CMAKE_COMMAND} -E copy_directory
#        "${PROJECT_SOURCE_DIR}/libs"
#        ${PROJECT_BINARY_DIR})

# Test
enable_testing()
add_executable(OES_GetProviderInfo cases/OES_GetProviderInfo.c ../header/oes.h )
target_link_libraries(OES_GetProviderInfo ${LIBRARIES})

add_executable(OSE_GetSealList cases/OSE_GetSealList.c ../header/oes.h)
target_link_libraries(OSE_GetSealList ${LIBRARIES})

add_executable(OES_GetSeal cases/OES_GetSeal.c ../header/oes.h)
target_link_libraries(OES_GetSeal ${LIBRARIES})

enable_testing()
add_test(NAME OES_GetProviderInfo COMMAND OES_GetProviderInfo)
add_test(NAME OSE_GetSealList COMMAND OSE_GetSealList)
